// 所有关于课程的接口
import request from '@/utils/request'

// 上传课程封面接口
export const uploadImgApi = (data) => {
  return request({
    url: "/VueHandler/UpLoadPicHandler",
    headers: { "Content-Type": "multipart/form-data" },
    method: "post",
    data
  })
}
// 添加课程基本信息接口
export const addCourseApi = (data) => {
  return request({
    url: "/VueHandler/CourseHandler?action=add",
    method: "post",
    data
  })
}
// 根据ID获取课程详情接口
export const getCourseByIdApi = (ID) => {
  return request({
    url: "/VueHandler/CourseHandler?action=getcourse",
    method: "get",
    params: { ID }
  })
}
// 给课程添加目录接口
export const addCourseDirApi = (data) => {
  return request({
    url: "/VueHandler/CourseHandler?action=adddirectory",
    method: "post",
    data
  })
}

// 获取课程列表接口
export const getCourseListApi = (data) => {
  return request({
    url: "/VueHandler/CourseHandler?action=show",
    method: "post",
    data
  })
}
// 课程上架下架方法
export const courseOnOffApi = (ID) => {
  return request({
    url: "/VueHandler/CourseHandler?action=state",
    method: "post",
    data: {
      ID: ID
    }
  })
}
// 课程删除
export const courseDeleteApi = (_id) => {
  return request({
    url: "/VueHandler/CourseHandler?action=delete",
    method: "post",
    data: {
      _id: _id
    }
  })
}
// 课程置顶接口
export const courseTopApi = (ID) => {
  return request({
    url: "/VueHandler/CourseHandler?action=top",
    methods: "post",
    data: {
      ID: ID
    }
  })
}
// 删除目录接口
export const delDirApi = (params) => {
  return request({
    url: "/VueHandler/CourseHandler?action=deleteDirectory",
    method: "get",
    params
  })
}
// 编辑目录接口
export const updateDirApi = (data) => {
  return request({
    url: "/VueHandler/CourseHandler?action=updateDirectory",
    method: "post",
    data
  })
}

// 给目录添加视频接口
export const addDirVideoApi = (params) => {
  return request({
    url: "/VueHandler/CourseHandler?action=addvideo",
    method: "get",
    params
  })
}

// 查询目录下添加的视频列表
export const getDirVideoListApi = (params) => {
  return request({
    url: "/VueHandler/VideoHandler?action=showdir",
    method: "get",
    params
  })
}
// 删除目录下的视频接口（删除课件）
export const delDirVideoApi = (params) => {
  return request({
    url: "/VueHandler/CourseHandler?action=delvideo",
    method: "get",
    params
  })
}
// 全部保存课程接口
export const saveCourseApi = (data) => {
  return request({
    url: "/VueHandler/CourseHandler?action=update",
    method: "post",
    data
  })
}